<?php
declare (strict_types = 1);

namespace app\command;

use app\model\Notice;
use app\model\Users;
use app\model\UsersSign;
use think\console\Command;
use think\console\Input;
use think\console\input\Argument;
use think\console\input\Option;
use think\console\Output;

class ScoreSign extends Command
{
    protected function configure()
    {
        // 指令配置
        $this->setName('scoresign')
            ->setDescription('the scoresign command');
    }

    protected function execute(Input $input, Output $output)
    {
		$rows = Users::where(['sign_notice'=>1])->select();
		foreach ($rows as $row){
			$today = UsersSign::where('users_id',$row->id)->whereTime('createtime','today')->find();
			if (!$today){
				Notice::create([
					'type'=>4,
					'users_id'=>$row->id,
					'content'=>'又到了签到时间了，赶紧签到吧！',
				]);
			}
		}
        // 指令输出
        $output->writeln('success');
    }
}
